<?php
header('Content-type: application/json;charset=utf-8');
require_once(dirname(__FILE__) . '/../../inc/config.inc.php');
IsModelPriv('goodsorder');
$tbname = '#@__tasktype';
//引入操作类
$field = isset($_POST['field']) ? $_POST['field'] : [];
$classname = empty($field['classname']) ? "" : $field['classname'];
$picurl = empty($field['picurl']) ? "" : htmlspecialchars($field['picurl']);
$truename = empty($field['truename']) ? "" : htmlspecialchars($field['truename']);
$orderid = empty($field['orderid']) ? 0 : intval($field['orderid']);
$action = empty($_POST['action']) ? "" : htmlspecialchars($_POST['action']);


//审核状态
if (!isset($field['checkinfo'])) {
    $checkinfo = 0;
} else {
    $checkinfo = 1;
}

$time=time();

if ($action == 'update') {
    $id = empty($field['id']) ? 0 : intval($field['id']);
    $dosql->ExecNoneQuery("UPDATE $tbname SET classname='$classname',orderid='$orderid',picurl='$picurl',`checkinfo`='$checkinfo',updatetime='$time' WHERE id=$id");

    $row_arr['code'] = 0;
    $row_arr['msg'] = "编辑成功";
    echo json_encode($row_arr);
}
if ($action == 'add') {

    $dosql->ExecNoneQuery("INSERT INTO $tbname (`classname`,`checkinfo`,`orderid`,`picurl`,`addtime`) VALUES ('$classname','$checkinfo','$orderid','$picurl','$time')");

    $row_arr['code'] = 0;
    $row_arr['msg'] = "添加成功";
    echo json_encode($row_arr);

}
if ($action == 'del') {
    $dosql->ExecNoneQuery("UPDATE $tbname  SET is_delete='1',deletetime='$time' WHERE id=$id ");
    $row_arr['code'] = 0;
    $row_arr['msg'] = "删除成功";
    echo json_encode($row_arr);
}